<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Role extends Authenticated{
	
	function __construct() {
		parent::__construct();
		$this->load->model("role_model");
                $this->load->model("fungsi_model");
		$this->load->model("user_model");
//		$this->user_model->is_access(1);
	}
	
	function index(){
		$this->list_role() ;
	}
	
        function list_role()
        {
            $data['list_role']=$this->role_model->get_all_role();
            $this->load->view('header');
            $this->load->view('role/list_role',$data);
            $this->load->view('footer');
        }
        
        function add_role()
        {
            $data['list_fungsi']=$this->fungsi_model->get_all_fungsi();
            $this->load->view('header');
            $this->load->view('role/add_role',$data);
            $this->load->view('footer');
        }
        
        function add_role_process()
        {
            $data = $_GET;
//            die(var_dump($_GET));
            $this->role_model->add_role($data);
            redirect(ROLE);
        }
        
        function edit_role($id)
        {
            $data = $this->role_model->get_role($id);
            $data['list_fungsi']=$this->fungsi_model->get_all_fungsi();
            $this->load->view('header');
            $this->load->view('role/form_edit_role',$data);
            $this->load->view('footer');
        }
        
        function edit_role_process()
        {
            $data = $_GET;
            $this->role_model->update_role($data);
            redirect(ROLE);
        }
        
        function delete_role($id)
        {
            $this->role_model->delete_role($id);
            redirect(ROLE);
        }
	
}
/** End of file */
